<template>
  <div>
    <div id="app">
      <div id="nav">
        <div class="nav-center">
          <div class="nav-Icon">
            <img src="@/assets/images/index/logo1.jpg" alt="Big Boat" />
          </div>
          <div class="Navigation">
            <ul class="Navigation-ul">
              <li class="Navigation-li">
                <a href="/">{{
                  $tc("header.Home")
                }}</a>
              </li>
              <li class="Navigation-li">
                <a href="/newsInformation">{{
                  $tc("header.News")
                }}</a>
              </li>
              <li class="Navigation-li">
                <a href="/manufacture">{{
                  $tc("header.Manufacture")
                }}</a>
              </li>
              <li class="Navigation-li">
                <a href="/productDisplay">{{
                  $tc("header.Product")
                }}</a>
              </li>
              <li class="Navigation-li">
                <a href="https://sm.mouldc.com/v1/">{{
                  $tc("header.Mall")
                }}</a>
              </li>
              <li class="Navigation-li">
                <a href="https://supply.mouldc.com">{{
                  $tc("header.Platform")
                }}</a>
              </li>
              <li class="Navigation-li">
                <a href="/contactus">{{
                  $tc("header.Contact")
                }}</a>
              </li>
            </ul>
          </div>
          <div class="nav-behind">
            <div class="Mobile-terminal">
              <div
                class="mask"
                v-if="showModal"
                @click="showModal = false"
              ></div>
              <div class="pop" v-if="showModal">
                <button @click="showModal = false" class="btn">
                  <img src="@/assets/images/index/logo7.jpg" alt="img" />
                </button>
              </div>
              <!-- <button @click="showModal = true" class="btn">
                {{ $tc("header.Wechat") }}
              </button> -->
            </div>
          </div>
          <div class="language">
            <img :src="item.label" v-for="item in languageImg" :key="item" @click="toggleLanguage(item)" alt="">
          </div>
          <div id="Icon">
            <a @click="showClick" class="iconfont"> &#xe6e1;</a>
          </div>
          <el-dropdown
            ref="dropdown1"
            trigger="contextmenu"
            style="margin-right: 30px,top:70px"
          >
            <template #dropdown>
              <el-dropdown-menu >
                <el-dropdown-item class="Navigation-li"
                  ><a href="/">{{
                    $tc("header.Home")
                  }}</a></el-dropdown-item
                >
                <el-dropdown-item class="Navigation-li">
                 <a @click="showModal = true" class="btn">
                  {{ $tc("header.Wechat")}}
                 </a>
                </el-dropdown-item>
                <el-dropdown-item class="Navigation-li"
                  ><a href="/newsInformation">{{
                    $tc("header.News")
                  }}</a></el-dropdown-item
                >
                <el-dropdown-item class="Navigation-li"
                  ><a href="/manufacture">{{
                    $tc("header.Manufacture")
                  }}</a></el-dropdown-item
                >
                <el-dropdown-item class="Navigation-li"
                  ><a href="/productDisplay">{{
                    $tc("header.Product")
                  }}</a></el-dropdown-item
                >
                <el-dropdown-item class="Navigation-li"
                  ><a href="https://sm.mouldc.com/v1/">{{
                    $tc("header.Mall")
                  }}</a></el-dropdown-item
                >
                <el-dropdown-item class="Navigation-li"
                  ><a href="https://supply.mouldc.com">{{
                    $tc("header.Platform")
                  }}</a></el-dropdown-item
                >
                <el-dropdown-item class="Navigation-li"
                  ><a href="/contactus">{{
                    $tc("header.Contact")
                  }}</a></el-dropdown-item
                >
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
      </div>
      <router-view></router-view>
    </div>
  </div>
  <Footer />
</template>

<script>
import { onMounted, ref, reactive, computed } from "vue";
import { useI18n } from "vue-i18n";
import { useStore } from "vuex";
// import routers from './router'
export default {
  data() {
    return {
      showModal: false,
    };
  },
  setup() {
    const languageImg = reactive([
      {label: require('@/assets/images/index/中国.jpg'), value: 'zh-CN'},
      {label: require('@/assets/images/index/美国.jpg'), value: 'en-US'},
      {label: require('@/assets/images/index/德国.jpg'), value: 'de-DE'}
    ])

    const { locale } = useI18n();
    const store = useStore();
    const toggleLanguage = (item) => {
      locale.value = item.value;
      store.commit('setLanguage', locale)
    }
    onMounted(() => {
      store.dispatch("getLanguage");
      locale.value = store.state.locale;
    });

    const showModal = ref(false)

    const currentPath = ref(window.location.hash)

    window.addEventListener('hashchange', () => {
      currentPath.value = window.location.hash
    })

    const dropdown1 = ref()
    function showClick() {
      dropdown1.value.handleOpen()
    }

    return {languageImg, toggleLanguage, showModal, dropdown1, showClick}
  },
};
</script>
<style scoped>
#Icon a {
  font-size: 70px;
  padding-top: 40px;
  display: none;
}
#nav {
  position: fixed;
  top: 0;
  width: 100%;
  background-color: #ffffff;
  z-index: 999;
}
.el-popper{
  top: 70px !important;
}
#app {
  /* background-color: red; */
  max-width: 1687px;
  padding: 0px auto;
  margin: 0px auto;
}
.nav-Icon img {
  width: 300px;
}
a:hover{
  color: red;
}
.Navigation {
  width: 60%;
}
.Navigation-ul {
  display: flex;
  list-style-type: none;
  justify-content: space-evenly;
}
.Navigation-li {
  padding-left: 25px;
  padding-top: 0px;
}
.Navigation-li a {
  text-decoration: none;
  color: black;
}
.nav-center {
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.mask {
  background-color: #000;
  opacity: 0.3;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}
.pop {
  background-color: #fff;
  position: fixed;
   left: 35%; 
  z-index: 2;
}
.btn {
  float: left;
  border: none;
  background-color: #ffffff;
  position: relative;
  font-size: 18px;
}
.language {
  width: 13%;
  height: 79px;
}
.language img {
  margin: 16px 10px 6px 0px;
  width: 60px;
  height: 40px;
}

.el-dropdown {
  margin: 0 !important;
}
.example-showcase{
  cursor: pointer;
  color: var(--el-color-primary);
  display: flex;
  align-items: center;
}
.Navigation-li a{
  font-size: 20px;
}

@media screen and (min-width: 1683px) {
  .nav-center{
    max-width: 1726px;
  }
}
@media screen and (max-width: 1683px) and (min-width: 666px) {
  .Navigation-ul {
    display: none;
  }
  .language {
    min-width: 220px;
  }
  .btn {
    min-width: 70px;
  }
  #Icon a {
    display: inline;
  }
  .nav-center{
    min-width: 665px;
  }
  .btn img{
    width: 70%;
    height: 70%;
  }
}
@media screen and (max-width: 666px) {
  .Navigation-ul {
    display: none;
    width: 200px;
  }
  .Navigation-li a{
  font-size: 15px;
}
  .language {
    min-width: 130px;
  }
  .language img{
    padding-top: 10px;
    width: 25%;
    height: 33%;
  }
  .btn {
    min-width: 60px;
    font-size: 15px;
  }
  .iconfont{
    width: 300px;
  }
  #Icon a {
    display: inline;
    font-size: 50px;
  }
  .nav-Icon img{
    width: 120px;
  }
  .pop {
  background-color: #fff;
  position: fixed;
   left: 15%; 
  z-index: 2;
}
.btn img{
    width: 70%;
    height: 70%;
  }
}
</style>

